﻿using UnityEngine;
using System.Collections;
using System;
using ProtoBuf.Meta;

namespace ProtoBuf.Serializers
{

    sealed class UnityQuaternionSerializer : IProtoSerializer
    {
        static readonly Type expectedType = typeof(Quaternion);

        public UnityQuaternionSerializer(ProtoBuf.Meta.TypeModel model) { }

        public Type ExpectedType { get { return expectedType; } }


        public bool RequiresOldValue
        { 
            get { return false; }
        }
        public bool ReturnsValue
        {
            get { return true; }
        }

        public object Read(object value, ProtoReader source)
        {
            Helpers.DebugAssert(value == null); // since replaces
            return BclHelpers.ReadUnityQuaternion(source); 
        }

        public void Write(object value, ProtoWriter dest)
        {
            BclHelpers.WriteUnityQuaternion((Quaternion)value, dest);
        }
    }


}
